package bookmanagement.operation.impl;

import bookmanagement.book.Book;
import bookmanagement.book.BookList;
import bookmanagement.operation.IOperation;


// 添加操作
public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行添加书籍操作");
        System.out.println("请输入书籍名称");
        String bookName = scanner.next();
        if (bookList.isBookContains(bookName)) {
            System.err.println("该书籍已存在，无需重复添加！");
            return;
        }
        System.out.println("请输入作者姓名");
        String author = scanner.next();
        System.out.println("请输入书籍价格");
        double price = scanner.nextDouble();
        System.out.print("请输入书籍类别 \n");
        String type = scanner.next();
        Book book = new Book(bookName,author,price,type);
        bookList.addBook(book);
        System.out.println("添加书籍成功!");
    }
}
